#ifndef __OPENSSL_LOGGER_H
#define __OPENSSL_LOGGER_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>  

#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>

typedef int boolean;
typedef unsigned char u_char;
typedef unsigned long u_long;
typedef unsigned int  u_int;
typedef unsigned short u_short;

#define LOG_TAG "OPENSSL_TEST"

#define MAX_16_LEN 16
#define MAX_32_LEN 32
#define MAX_64_LEN 64
#define MAX_128_LEN 128
#define MAX_256_LEN 256
#define MAX_512_LEN 512
#define MAX_1024_LEN 1024
#define MAX_INT_LEN 65535

#define false 0
#define true 1
#define ERROR_NUM_COMPATIBILITY -9999  // exit时兼容性错误类型的返回值

#ifdef DEBUGGABLE
#define debug_logger 1
#else
#define debug_logger 0
#endif
#define __ADDRESS(x) logger_warn_fmt("------->>> PID:%d, LINE:%d, '%s' is %p\n", getpid(), __LINE__, #x, (x));
#define __DEBUG__ if(debug_logger) { logger_warn_fmt("------->>> PID:%ld, %20s() %s:%d\n", getpid(), __FUNCTION__, __FILE__, __LINE__);}
#define __ISNULL(x) logger_warn_fmt("------->>> PID:%d, LINE:%d, '%s' is %s\n", getpid(), __LINE__, #x, ((x) == NULL ? "null" : "not null"));

#define __CANDY_MALLOC(x, y) candy_malloc(x, y)
#define __CANDY_FREE(x) candy_free(#x, x)

enum {
    INFO = 0,
    WARN,
    ERROR
};

void logger_info(const char *msg);
void logger_warn(const char *msg);
void logger_err(const char *msg);

void logger_info_fmt(const char *fmt, ...);
void logger_warn_fmt(const char *fmt, ...);
void logger_err_fmt(const char *fmt, ...);

void logger_fmt(const char *tag, int level, const char *fmt, va_list args);

void *candy_malloc(const char *objName, int size);
void candy_free(const char *objName, void *obj);

#endif